
#include "../libc/rw_share_mem.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "VirtualCamera.h"
#include "GxCamera.h"
const unsigned int MEMORY_SIZE = 1920 * 1080 * 3;

int main( )
{
    VirtualCamera cam0("/home/wang/Documents/ComputerVision/resource/Videos/src/2.mp4");
    // GxCamera cam0(0);
    Camera* cam = (Camera*)&cam0;
    cam->open();


    if ( 0 != init_share_mem( MEMORY_SIZE ) )
    {
        printf( "init share mem error\n" );
        return -1;
    }
    else
        while ( true )
        {
            Mat m = cam->getFrame();
            cout << m.cols << " " << m.rows << endl;
            if ( 0 != write_share_mem( (char*)m.data, MEMORY_SIZE ) )
            {
                printf( "write share memory error" );
                return -2;
            }
            usleep( 10000 ); // 10 ms
			// sleep(1);
        }

    return 0;
}
